package com.handpay.nocardpay.baselibrary.main.mine.view.fragment;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.TextView;

import com.handpay.nocardpay.baselibrary.R;
import com.handpay.nocardpay.baselibrary.commbase.view.fragment.BaseFragment;
import com.handpay.nocardpay.baselibrary.config.NoCardPayConfig;
import com.handpay.nocardpay.baselibrary.logutils.HPLog;
import com.handpay.nocardpay.baselibrary.main.widget.SwitchButton;
import com.handpay.nocardpay.baselibrary.utils.AccountUtils;
import com.handpay.nocardpay.baselibrary.utils.CommonUtils;
import com.handpay.nocardpay.baselibrary.widget.CustomTextView;

/**
 * Created by sxshi on 2017/8/14.
 * user basicInfo
 */

public class BasicInfoFragment extends BaseFragment {
    private CustomTextView mPhoneNumber, mModifyPhone, mModifyPwd;
    private TextView mUserName;
//    private SwitchButton switch_managerguest_button;

    public static BasicInfoFragment newInstance() {
        Bundle args = new Bundle();
        BasicInfoFragment fragment = new BasicInfoFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_basicinfo;
    }

    @Override
    public String getFragmentTitle() {
        return getString(R.string.mine_basic_info);
    }

    @Override
    public void initView(View view) {
        Toolbar toolbar = (Toolbar) view.findViewById(R.id.toolbar);
        initToolbar(toolbar, true);
        mUserName = (TextView) view.findViewById(R.id.tv_username);
        mPhoneNumber = (CustomTextView) view.findViewById(R.id.ctv_phone);
        mModifyPhone = (CustomTextView) view.findViewById(R.id.ctv_modify_phone);
        mModifyPwd = (CustomTextView) view.findViewById(R.id.ctv_modify_pwd);
//        switch_managerguest_button = (SwitchButton) view.findViewById(R.id.switch_managerguest_button);
    }

    @Override
    public void initListener() {
        mModifyPhone.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                start(ModifyPhonePreFragment.newInstance());
            }
        });
        mModifyPwd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                start(ModifyPwdFragment.newInstance());
            }
        });

//        switch_managerguest_button.setOnCheckedChangeListener(this);
    }

    @Override
    public void initData(Bundle savedInstanceState) {
        String userName = AccountUtils.getUserName(_mActivity);
        String phone = AccountUtils.getAccountPhone(_mActivity);
        HPLog.d(HPLog.SSX_TAG, "userAccount" + userName);
        HPLog.d(HPLog.SSX_TAG, "phone" + phone);
        mUserName.setText(userName);
        mPhoneNumber.setRightTv(CommonUtils.formatPhoneNumber(phone), null);

        //无卡支付 不能修改登录密码
        if (NoCardPayConfig.isNoCardPay) {
            mModifyPwd.setVisibility(View.GONE);
        } else {
            mModifyPwd.setVisibility(View.VISIBLE);
        }
    }

//    @Override
//    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//        HPLog.i(HPLog.YL_TAG, "onCheckedChanged:" + isChecked);
//        start(GestureLockSetFragment.newInstance());
//    }
}
